package panel.viewSpots.navigation
{
	import assists.HtmlText;
	import assists.TextFieldUtils;
	import assists.resource.ResourceLoader;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	import main.ClientConstants;
	
	public class SpotVisitedBtn extends Sprite
	{
		private var _loader:ResourceLoader;
		private var _stage:Stage;
		private var _label:TextField = new TextField();
		private var _btn:Sprite = new Sprite();
		public var isVisited:Boolean;
		public function SpotVisitedBtn(loader:ResourceLoader,stage:Stage)
		{
			_loader = loader;
			_stage = stage;
			init();
		}
		
		private function init():void
		{
			var distance:Number = _stage.stageHeight * 0.09;
			_label.autoSize = "left";
			_label.mouseEnabled = false;
			this.graphics.beginFill(0x0099ff,0.8);
			this.graphics.drawRect(0,0,_stage.stageWidth,distance);
			this.graphics.endFill();
			TextFieldUtils.setHtmlText(_label,HtmlText.formatSizeColor("我已经来过该景点了",0xffffff,int(distance * 0.3)));
			_label.y = (distance - _label.height) * 0.5;
			_btn.addChild(_loader.uiManager.generateBmp(_loader.uiManager.visitedPng));
			_btn.height = _btn.width = distance;
			_btn.x = _stage.stageWidth - _btn.width - _stage.stageWidth * 0.05;
			
			this.addChild(_label);
			this.addChild(_btn);
			
			_btn.addEventListener(MouseEvent.CLICK,clickHandler);
		}
		
		protected function clickHandler(event:MouseEvent):void
		{
			isVisited = !isVisited;
			if(isVisited)
			{
				_btn.filters = [];
			}else
			{
				_btn.filters = [ClientConstants.GLOBAL_FILTER_GREY];
			}
		}
		
	}
}